public class Test6 {
    public static int countNum = 0;

    //a->c   a->b  c->b  a->c  b-> a  b->c  a->c
    public static void hanoi(int n, char pos1, char pos2, char pos3) {
        if (n == 1) {
            move(pos1, pos3);
            return;
        }
        hanoi(n - 1, pos1, pos3, pos2);
        move(pos1, pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }

    public static void move(char posSrc, char posDest) {
        countNum++;
        System.out.print(posSrc + "->" + posDest + " ");
    }

    public static void main(String[] args) {
        hanoi(4, 'A', 'B', 'C');
        System.out.println(countNum);
    }
}